<template>
  <view class="setting-container" :style="{height: `${windowHeight}px`}">
    <view class="menu-list">
      <view class="list-cell list-cell-arrow" @click="handleToPwd">
        <view class="menu-item-box">
          <view class="iconfont icon-password menu-icon"></view>
          <view>修改密码</view>
        </view>
      </view>
      <view class="list-cell list-cell-arrow" @click="handleToUpgrade">
        <view class="menu-item-box">
          <view class="iconfont icon-refresh menu-icon"></view>
          <view>检查更新</view>
          <zy-update theme="blue" :updateurl="updateurl" :noticeflag="true" :h5preview="false"
                     ref="zyupgrade" :showupdateTips="showupdatetips"></zy-update>
        </view>
      </view>
      <view class="list-cell list-cell-arrow" @click="handleCleanTmp">
        <view class="menu-item-box">
          <view class="iconfont icon-clean menu-icon"></view>
          <view>清理缓存</view>
        </view>
      </view>
      <view class="list-cell list-cell-arrow" @click="handleUses">
        <view class="menu-item-box">
          <view class="iconfont icon-user menu-icon"></view>
          <view>账号管理</view>
        </view>
      </view>
    </view>
    <view class="cu-list menu">
      <view class="cu-item item-box">
        <view class="content text-center" @click="handleLogout">
          <text class="text-black">退出登录</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import ZyUpdate from '../../../components/zy-upgrade/zy-upgrade.vue'
import {baseUrl} from "../../../config";
  export default {
    data() {
      return {
        updateurl: baseUrl + '/mesLogin/checkNewApp',
        windowHeight: uni.getSystemInfoSync().windowHeight,
        updateFlag: true,
      }
    },
    components:{
      ZyUpdate
    },
    methods: {
      handleToPwd() {
        this.$tab.navigateTo('/pages/mine/pwd/index')
      },
      handleToUpgrade() {
        if (uni.getStorageSync('cacneUpdateFlag') === true) {
          uni.setStorageSync('cacneUpdateFlag', false);
          return;
        }
        this.$refs.zyupgrade.check_update(true);
      },
      showupdatetips:function(flag) {
        if(flag === 0){
          uni.showToast({
            title: '已经是最新版本了',
            icon:'none'
          });
        }
      },
      handleCleanTmp() {
        this.$modal.showToast('模块建设中~')
      },
      handleUses() {
        this.$tab.navigateTo('/pages/mine/setting/userManage')
      },
      handleLogout() {
        this.$modal.confirm('确定注销并退出系统吗？').then(() => {
          this.$store.dispatch('LogOut').then(() => {
            this.$tab.reLaunch('/pages/index')
            uni.setStorageSync('appUser', null);
          })
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .page {
    background-color: #f8f8f8;
  }

  .item-box {
    background-color: #FFFFFF;
    margin: 30rpx;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 10rpx;
    border-radius: 8rpx;
    color: #303133;
    font-size: 32rpx;
  }
</style>
